package org.twnmayberry.blimpl;

import java.util.List;

import org.twnmayberry.bl.PoiMgmt;
import org.twnmayberry.bo.Activity;
import org.twnmayberry.bo.POI;
import org.twnmayberry.dao.POIDAO;

public class PoiMgmtImpl implements PoiMgmt {

	private POIDAO poiDAO;
	
	
	public PoiMgmtImpl(POIDAO dao) {
		poiDAO = dao;
	}
	
	public void addPOI(POI newPOI) {
		poiDAO.createPOI(newPOI);
	}

	public void addActivity(long poiID, Activity newActivity) {
		POI tempPOI = poiDAO.getPOIByID(poiID);
		tempPOI.getActivities().add(newActivity);
		poiDAO.updatePOI(tempPOI);
	}

	public POI getPOI(long id) {
		return poiDAO.getPOIByID(id);
	}

	public boolean isDangerous(POI badGuy) {
        for(Activity activity : badGuy.getActivities()) {
        	if(activity.getDescription().contains("dangerous")) {
        		return true;
        	}
        }
        return false;
	}

	@Override
	public List<POI> getAllPOI() {
		return poiDAO.getAllPOIs();
	}
	
	@Override
	public void updatePOI(POI updateGuy) {
		poiDAO.updatePOI(updateGuy);
	}

	@Override
	public List<POI> getPOIsByName(String firstName, String middleName, String lastName) {
		return  poiDAO.getPOIsByFirstMiddleLastName(firstName, middleName, lastName);
			}

}
